// Detect Key Events
// $(window).on("keydown", function(event){
// 插件来源: http://www.jq22.com/jquery-info11724

var osc = {};

$(window).keydown(function (event) {
  var code = (event.keyCode ? event.keyCode : event.which);
  if (osc[code])
    return;
  $("li[data-code='" + code + "']").addClass("active")
  var key = $("li[data-code='" + code + "']").data("key");
  var code = $("li[data-code='" + code + "']").data("code");
});

$(window).keyup(function (event) {
  var code = (event.keyCode ? event.keyCode : event.which);
  $("li[data-code='" + code + "']").removeClass("active")
  var key = $("li[data-code='" + code + "']").data("key");
  var code = $("li[data-code='" + code + "']").data("code");
  if (!osc[code])
    return;
});

// Detect Mouse Events
$(".key-wrapper li").mousedown(function (event) {
  $(this).addClass("active");
  var key = $(this).data("key");
  var code = $(this).data("code");
});

$(".key-wrapper li").mouseup(function (event) {
  $(this).removeClass("active");
  var key = $(this).data("key");
  var code = $(this).data("code");
});